package com.springmvc.api.service.impl;

import com.springmvc.api.dao.LoginDao;
import com.springmvc.api.dao.LoginRedisDao;
import com.springmvc.api.service.LoginService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by cheng.xi on 12/1/15.
 */
@Service
public class LoginServiceImpl implements LoginService{
    Logger logger = Logger.getLogger(LoginServiceImpl.class);

    @Autowired
    private LoginDao loginDao;

    @Autowired
    private LoginRedisDao loginRedisDao;

    @Override
    @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRED)
    public boolean login() {
        //登录
        boolean result = loginDao.login();
        //登陆成功之后需要放在redis中
        loginRedisDao.clearLoginFailTimes("ssss");
        //logger.debug("插入结果:" + result);
        //int i = 0;
        //i = 1/0;
        //logger.debug("i:" + i);
        return false;
    }
}
